/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javamu;
import java.util.HashMap;

/**
 *
 * @author Administrator
 */
public class HashMapClass {
	
	private final HashMap<String, StudentClass> students = new HashMap<>();
	
	public void addStudent(String id, StudentClass student){
		this.students.put(id, student);
	}
	
	public void delStudent(String id){
		this.students.remove(id);
	}
	
	public void edtStudent(String id, StudentClass student){
		this.students.put(id, student);
	}
	
	public void addAllStudent(){
		this.students.putAll(students);
	}
	
	public String getStudents(){
		students.entrySet().stream().forEach((entry) -> {
			String key = entry.getKey();
			StudentClass value = entry.getValue();
			System.out.println("KEY:" + key + ",键值:" + value);
		});
		return this.students.toString();
	}
	
	
	public static void main(String[] args) {
		HashMapClass hm = new HashMapClass();
		StudentClass st01 = new StudentClass(10, "陈峰展");
		StudentClass st02 = new StudentClass(20, "梁燕萍");
		StudentClass st03 = new StudentClass(1, "插班生");
		StudentClass st04 = new StudentClass(30, "陈大神");
		hm.addStudent("18206084310", st02);
		hm.addStudent("14759786559", st01);
		hm.addStudent("001", st03);
		System.out.println(hm.getStudents());
		hm.edtStudent("001", st04);
		System.out.println(hm.getStudents());
		hm.delStudent("001");
		System.out.println(hm.getStudents());
	}
}
